// 找到缺失的数字
// 测试链接 : https://leetcode.cn/problems/missing-number/
public class MissingNumber {
    public static void main(String[] args) {
        int[] nums = {0,1,5,2,3,4,7,8,9};
        System.out.println(missingNumber(nums));
    }

    public static int missingNumber(int[] nums) {
        int eorAll = 0, eorHas = 0;
        for(int i = 0; i < nums.length; ++i) {
            eorAll^=i;
            eorHas^=nums[i];
        }
        eorAll^=nums.length;
        return eorAll^eorHas;
    }
}
